﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HRM.BLL;
using HRM.DAL.DAO;
using HRM.DAL.Report;

namespace HRM.UI.HigherManagementUI.Profile
{
    public partial class ManagementHome : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            GetEmployeeInfo();
            GetNotice();
            CountMsg();
        }

      private void GetEmployeeInfo()
        {
            Code code = new Code();
            code.CodeName = Session["Code"].ToString();
            EmployeeManager manager = new EmployeeManager();
            ViewEmployee viewEmployee = new ViewEmployee();
            viewEmployee = manager.SearchEmployeeByCode(code);
            //userNameLbl.Text = viewEmployee.Employee.Name;
            empImage.ImageUrl = viewEmployee.Photo.FileName;
            userDesignation.Text = viewEmployee.Designation.Title;
            joinDate.Text = (viewEmployee.Employee.JoiningDate).ToShortDateString();
            empCode.Text = code.CodeName;
        }
      private void GetNotice()
      {
          NoticeManager manager = new NoticeManager();
          int i = 0;
          foreach (Notice notice in manager.GetAllNotices())
          {
              if (i == 0)
              {
                  NoticeTitle.Text = notice.Subject;
              }
              i++;
          }
      }

      private void CountMsg()
      {
          MessageManager manager = new MessageManager();
          Code senderCode = new Code();
          senderCode.CodeName = Session["Code"].ToString();
          unreadLbl.Text = manager.CountUnRead(senderCode).ToString();

      }

    }
}